import { getSalesCenterDetail } from "../../../api/custBaseController";
import AUTH from "../../../utils/auth";
import { successfulWithdrawalTmplIds } from "../../../utils/config";

Page({
  /**
   * 页面的初始数据
   */
  data: {
    content:{
      modalView: false,
      title: '温馨提示',
      message: '需要完成实名认证，才可以提现！'
    },
    navList:[
      {
        name:'客户一人数',
        url:'/static/images/dr1.png',
      },
      {
        name:'客户二人数',
        url:'/static/images/dr2.png',
      },
    ],
    navListIndex: 0,

    salesDetail:'',   //销售中心
  },
  onShow(){
    this.getSalesCenterDetail()
  },
  /**
   * 提取
   */
  extract(){
    let realName =  AUTH.checkRealName()
    if (!realName) {
      this.setData({
        ['content.modalView']: true
      })
      return
    }else{
      wx.requestSubscribeMessage({
        tmplIds: successfulWithdrawalTmplIds,
        complete: ()=>{
          wx.navigateTo({
            url: '/pages/salesCenter/withdrawCash/index'
          })
        }
      })
    }
  },
    /**
   * 弹窗确认
   */
  handlerOk(){
    wx.navigateTo({
      url: '/pages/registerRealName/index',
    })
    this.setData({
      ['content.modalView']: false
    })
  },
    /**
   * 弹窗取消
   */
  handlerNo(){
    this.setData({
      ['content.modalView']: false
    })
  },
  /**
   * 销售中心
   */
  async getSalesCenterDetail(){
    let resolve = await getSalesCenterDetail({
      custId: wx.getStorageSync('custId'),
    })
    this.setData({
      salesDetail:resolve.data,
    })
  },
  /**
   * 切换导航
   */
  changeNav(e){
    let { index } = e.currentTarget.dataset
    this.setData({
      navListIndex: index
    })
  }
})